package com.matt.repository.courseV2;

import com.matt.domain.courseV2.VendorCourseContent;
import com.matt.domain.courseV2.VendorTimeContent;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface VendorCourseContentRepository extends JpaRepository<VendorCourseContent, String>, JpaSpecificationExecutor<VendorCourseContent> {

    @Query(value ="SELECT * FROM `tc_course_content` where courseId = ?1   and deleted = 0 ORDER BY orderNum",nativeQuery = true)
    List<VendorCourseContent> findByCourseIdOrderByOrderNumAsc(String courseId);


    @Query(value ="SELECT * FROM `tc_course_content` where courseId = ?1 and detailsType = ?2  and deleted = 0 ORDER BY orderNum",nativeQuery = true)
    List<VendorCourseContent> findByCourseIdAndDetailsTypeOrderByOrderNumAsc(String courseId,Integer detailsType);

    @Query(value ="SELECT * FROM `tc_course_content` where vendorPackageId = ?1   and deleted = 0 ORDER BY orderNum",nativeQuery = true)
    List<VendorCourseContent> findByVendorPackageIdOrderByOrderNumAsc(String vendorPackageId);

    @Query(value ="SELECT * FROM `tc_course_content` where vendorPackageId in (SELECT  packageV2Id FROM  tc_vendor_course_rel_packagev2 WHERE  vendorCourseId = ?1)   and deleted = 0 ORDER BY orderNum",nativeQuery = true)
    List<VendorCourseContent> findVendorPackageIdOrderByOrderNumAsc(String courseId);

    @Query(value ="SELECT * FROM `tc_course_content` where parentId = ?1   and deleted = 0 ORDER BY orderNum",nativeQuery = true)
    List<VendorCourseContent> findByParentIdOrderByOrderNumAsc(String parentId);
}